package easy;

public class Solution_680 {

    public boolean validPalindrome(String s) {
        for (int i = 0, j = s.length() - 1; i < j; i++, j--) {
            if (s.charAt(i) != s.charAt(j)) {
                return palindrome(s, i + 1, j) || palindrome(s, i, j - 1);
            }
        }
        return true;
    }

    private boolean palindrome(String s, int begin, int end) {
        for (int q = begin, p = end; q < p; q++, p--) {
            if (s.charAt(q) != s.charAt(p)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Solution_680 model = new Solution_680();
        System.out.println(model.validPalindrome("aba"));
        System.out.println(model.validPalindrome("acbba"));
    }
}
